import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
import { ModifierOption } from './modifierOption';

@Define.Table({ TableName: 'modifier' })
export class Modifier extends EntityObjectType<Modifier>{
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        IsIndex: true
    })
    productId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        // IsIndex: true
    })
    modifierStoreId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    rule: string;

    @Define.Column({
        DataType: Define.DataType.BOOL
    })
    required: boolean;

    @Define.Column({
        DataType: Define.DataType.INT
    })
    index: number;

    @Define.Mapping({
        Mapping: 'ModifierOption',
        MappingKey: 'modifierId'
    })
    modifierOptions: ModifierOption[];

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}

const ModifierRule = {
    Single: 'single',
    Multi: 'multi'
}